package com.example.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.example.Mapper.OutStorageDao;
import com.example.pojo.Saleinfo;
import com.example.pojo.Saleunstorage;

@Service
@Transactional(propagation=Propagation.REQUIRED)
public class OutStorageBiz{
	@Autowired
	private OutStorageDao odao;
	
	//历史交易记录查询
	public List<Saleunstorage> queryByCust(String id) {

		return null;
	}

	//查询明细表信息
	public List<Saleinfo> queryInfo(String id) {
		return odao.queryInfo(id);
	}

	//主祥查询
	public List<Saleunstorage> queryAll(Integer pagesize) {
		List<Saleunstorage> data = odao.queryAll(pagesize);
		for (Saleunstorage s : data) {
			s.setInfo(odao.queryInfo(s.getBillNo()));
		}
		return data;
	}

	//如果存在相同编号，删除在新增
	public void addorModify(Saleunstorage sale) {
		if(odao.count(sale.getBillNo())>0){
			odao.delete(sale.getBillNo());
		}
		odao.addorModify(sale);
	}

	//删除
	public void delete(String id) {
		odao.delete(id);
	}

	//修改是否审核
	public void updateState(String id) {
		odao.updateState(id);
	}
	
}
